/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mybean;

import java.text.DecimalFormat;
import java.util.ArrayList;

/**
 *
 * @author Phu
 */
public class Cart {

    private ArrayList<BookInCart> cart;
    private float totalCash;
    private int totalQuantity;

    public Cart() {
        cart = new ArrayList<BookInCart>();
        totalCash = 0;
        totalQuantity = 0;
    }

    public void add(BookInCart bookInCart) {
        cart.add(bookInCart);
        DecimalFormat myFormatter = new DecimalFormat("##.##");
        this.totalCash += bookInCart.getTotalCash();
        this.totalCash = Float.parseFloat(myFormatter.format(this.totalCash));
        this.totalQuantity += bookInCart.getQuantity();
    }

    public ArrayList<BookInCart> getCart() {
        return cart;
    }

    public float getTotalCash() {
        return totalCash;
    }

    public int getTotalQuantity() {
        return totalQuantity;
    }        
}
